package cn.ikun.mzw.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcUtils {
    public  static  int update(String sql) throws  Exception{

        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql://localhost:3306/test?useSSL=false";
        String username="root";
        String password="root";
        Connection connection = DriverManager.getConnection(url, username, password);
        Statement statement = connection.createStatement();
        return statement.executeUpdate(sql);



    }
    public  static void select(String sql) throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        String url ="jdbc:mysql://localhost:3306/test?useSSL=false";
        String username = "root";
        String password="root";
        Connection connection = DriverManager.getConnection(url,username,password);
        Statement statement = connection.createStatement();
        ResultSet set = statement.executeQuery(sql);
        while(set.next()) {
            String c1 = set.getString(1);
            System.out.println("c1 = " + c1);

        }
    }
}
